<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <style>
        .flex{display: -webkit-box; display: -webkit-flex; display: flex;}
        html,body{
            background-color: white;
        }
    </style>
</head>
<body>
    <div style="width: 100%; height: 0.20rem"></div>
    <div class="flex" style="width: 100%; height: 1.60rem; justify-content: center;">
        <textarea id="content" placeholder="请在此输入您的意见" style="width: 3.19rem; height: 1.60rem; border-style: solid; border-width: 0.01rem; border-color: #D0D0D0; border-radius: 0.06rem; padding: 0.12rem;"></textarea>
    </div>
    <div class="flex" style="width: 100%; margin-top: 0.44rem; justify-content: center">
        <input id="contract" style="width: 3.19rem; height: 0.42rem; border-style: solid; border-width: 0.01rem; border-color: #D0D0D0; border-radius: 0.06rem; padding-left: 0.12rem; padding-right: 0.12rem;" placeholder="请在此输入您的联系方式">
    </div>
    <div class="flex" style="width: 100%; height: 0.45rem; margin-top: 1.20rem; justify-content: center;">
        <div style="width: 2.97rem; height: 0.45rem; border-radius: 0.28rem; background-color: #A0522C; color: white; line-height: 0.45rem; text-align: center; font-size: 0.15rem;" tapmode onclick="sendFeedback()">提交</div>
    </div>
</body>
</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common/common.js"></script>
<script type="text/javascript">
    var contentEl, contractEl;
    apiready = function () {
        contentEl = $api.byId('content');
        contractEl = $api.byId('contract');
    }

    function sendFeedback() {
        if ($api.val(contentEl) != "") {
            api.ajax({
                url: apiUrl + '/me/feedback',
                tag: '/me/feedback',
                method: 'post',
                data: {
                    values: {
                        token: $api.getStorage("token"),
                        content: $api.val(contentEl),
                        contract: $api.val(contractEl),
                    }
                }
            }, function(ret, err) {
                if (ret) {
                    if (ret.code == 0) {
                        api.closeWin();
                    } else {
                        api.toast({
                            msg: ret.err_msg,
                            duration: 2000,
                            location: 'middle'
                        });
                    }
                } else {
                    // api.alert({ msg: JSON.stringify(err) });
                }
            });
        } else {
            api.toast({
                msg: "请填写意见",
                duration: 2000,
                location: 'middle'
            });
        }
    }
</script>
